<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>下属考勤</title>
    <link rel="stylesheet" type="text/css" href="mode/weui/weui.min.css"/>
    <link rel="stylesheet" type="text/css" href="web/res/fontawesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="webmain/css/rui.css">
    <script type="text/javascript" src="js/base64-min.js"></script>

    <script type="text/javascript" src="webmain/we/ying/dist/jquery.min.js"></script>
    <script type="text/javascript" src="webmain/we/ying/ying.js"></script>

    <script type="text/javascript" src="webmain/we/ying/dist/dropload.js"></script>
    <script type="text/javascript" src="webmain/we/ying/dist/dropload.min.js"></script>
    <link rel="stylesheet" href="webmain/we/ying/dist/dropload.css">
    <style>
        body,html{background-color:#f1f1f1;}

        .weui_tab{position:fixed;bottom:0px;width:100%;height:50px}
        .weui_navbar_item{font-size:16px;}
        .weui_navbar_item span{position:absolute;left:3px;top:3px}
        .weui_navbar_item:active{background-color:#f5f5f5}


        body,html{
            height: 100%;
        }

        ul li{
            width:90%; margin-left: 5%; margin-bottom: 20px; border-radius: 5px; display: flex;flex-direction:column; background-color: white;
        }

        li span{margin: 5px 10px;}

    </style>
    <script>



        var json1 = <?=json_encode($dataArr)?>;

        var json2 = <?=json_encode($xxdataArr)?>;

        var json3 = <?=json_encode($lowidArr)?>;

        var json4 = <?=json_encode($lowArr)?>;

        var page =0;

        var xxarr =[];

        for (var i = 0; i< json2.length;i++ ){

            var obj = json2[i];
            xxarr.push(obj.dt)
        }

        var weeks = ["星期一","星期二","星期三","星期四","星期五","星期六","星期日"]

        var d = new Date;

        var day=d.getDate()

        var month=d.getMonth() + 1

        var year=d.getFullYear()

        var timecurrent = year + "-" + month + "-" + day;

        var sincetime = "2017-08-01";

        var tmp = timecurrent.split("-");

        var T1 = new Date(tmp[0],tmp[1]-1,tmp[2]);

        tmp = sincetime.split("-");

        var T2 = new Date(tmp[0],tmp[1]-1,tmp[2]);

        var sincedays = days(T1,T2);

        var dropload;

        var refresh = 0;

        function days(t1,t2) {

            return (t1.getTime() - t2.getTime())/60/60/24/1000
        }


        var ulhtml = '';



        function mykaoqin() {

            window.history.back();

        }


        function load(){

            dropload = $('.element').dropload({

                scrollArea : window,

                loadDownFn : function(me){

                    $.ajax({

                        type: 'POST',
                        url: "http://oa.wxlion.com/index.php?a=lowerkq&m=ying&d=we&num=kqdkjl&show=we",
                        //url: "http://localhost/oa/public_html/index.php?a=lowerkq&m=ying&d=we&num=kqdkjl&show=we",

                        data: {

                            page:++page
                        },
                        datatype: "json",
                        success: function(result) {


                            var arr = eval(result);

                            json4 = arr;

                            lowerkaoqin();

                            me.resetload();    // 每次数据加载完，必须重置

                            if(!json4.length && page*3 > sincedays){

                                dropload.lock('down');
                                me.noData();
                                me.resetload();

                            }

                        },
                        //调用出错执行的函数
                        error: function(error1) {


                        }
                    });

                }

            });
        }

        window.onload=function(){

            load();
            $("#kqul").html(ulhtml);
        }


        function lowerkaoqin() {



            for (var i = 3*page-3; i < 3*page; i++) {

                if(i > sincedays){break;}

                var d = new Date;

                d.setDate(d.getDate() - i);

                var day=d.getDate()

                var month=d.getMonth() + 1

                var year=d.getFullYear()

                if (month >= 1 && month <= 9) {
                    month = "0" + month;
                }

                if (day >= 1 && day <= 9) {
                    day = "0" + day;
                }

                var time = year + "-" + month + "-" + day;


                var dateArray = time.split("-");
                var  date1 = new Date(dateArray[0], parseInt(dateArray[1] - 1), dateArray[2]);
                var currentWeek = "星期" + "日一二三四五六".charAt(date1.getDay());



                if(!array_contain(xxarr,time)){

                    for (var n = 0; n < json3.length; n++){

                        var j3 = json3[n];
                        if(contain(j3,time)){

                            var obj1 = contain(j3,time);

                            if(obj1.max != obj1.min){

                                ulhtml +='<li > <div style="display: flex;width: 100%; flex-direction: row; justify-content: space-between;background-color: rgb(27,205,138) ; border-radius: 5px 5px 0px 0px;"><span>'+ time + '&nbsp&nbsp&nbsp'+ j3.name+'</span><span>'+ currentWeek +'</span></div><span style="margin:5px 10px;">签到 '+ obj1.min.substr(11,8) + '&nbsp&nbsp&nbsp' + obj1.label + ' </span><span style="margin:5px 10px;">签退 '+ obj1.max.substr(11,8) + '&nbsp&nbsp&nbsp' + obj1.label + '</span> </li>';
                            }
                            else{

                                ulhtml +='<li > <div style="display: flex;width: 100%; flex-direction: row; justify-content: space-between;background-color: rgb(27,205,138) ; border-radius: 5px 5px 0px 0px;"><span>'+ time + '&nbsp&nbsp&nbsp'+ j3.name+'</span><span>'+ currentWeek +'</span></div><span style="margin:5px 10px;">签到 '+ obj1.min.substr(11,8) + '&nbsp&nbsp&nbsp' + obj1.label + ' </span><span style="margin:5px 10px; display: flex-direction:row;;">签退  &nbsp&nbsp&nbsp 未打卡 </span> </li>';
                            }

                        }
                        else{

                            ulhtml +='<li ><div style="display: flex;width: 100%; flex-direction: row; justify-content: space-between;background-color: rgb(27,205,138) ; border-radius: 5px 5px 0px 0px;"><span>'+ time + '&nbsp&nbsp&nbsp'+ j3.name+'</span><span>'+ currentWeek +'</span></div><span style="margin:5px 10px;">签到 &nbsp&nbsp&nbsp 未打卡 </span><span style="margin:5px 10px; display: flex-direction:row;;">签退  &nbsp&nbsp&nbsp 未打卡 </span> </li>';
                        }

                    }

                }
            }


            $("#kqul").html(ulhtml);

        }

        function contain(s,time) {

            for (var i=0; i<json4.length;i++){

                var obj = json4[i];
                if(obj.date == time && obj.uid == s.id){

                    return obj;
                }
            }

            return false;

        }


        function array_contain(array, obj){
            for (var i = 0; i < array.length; i++){
                if (array[i] == obj)//如果要求数据类型也一致，这里可使用恒等号===
                    return true;
            }
            return false;
        }


    </script>
</head>






<div class="element" style="width: 100%;  margin-top: 10px; overflow: auto;">

    <ul id="kqul">


    </ul>

</div>




<div style="height:50px;overflow:hidden"></div>
<div id="footerdiv" style="z-index:5" class="weui_tab">
    <div class="weui_navbar weui_tabbar">
        <div class="weui_navbar_item" onclick="mykaoqin()">我的考勤</div>

    </div>
</div>


</html>